<template>
	<view class="container">
		<view class="bill" v-if="showQuery">
			<view class="bill_item" v-for="item in billDetail" :key="item.clientBillId">
				<Bill title="退卡状态" :no="item.clientBillNo">
					<view class="detail_item">
						<view class="detail_title">退卡金额</view>
						<view class="detail_content advance_amount">
							{{item.amount}} 元</view>
					</view>
					<view class="detail_item">
						<view class="detail_title">退卡人姓名</view>
						<view class="detail_content">{{item.empName}}</view>
					</view>
					<view class="detail_item" >
						<view class="detail_title">IC卡号</view>
						<view class="detail_content">{{item.cardNo}}</view>
					</view>
					<view class="detail_item">
						<view class="detail_title">发起时间</view>
						<view class="detail_content">{{item.billTime}}</view>
					</view>
					<view class="detail_item">
						<view class="detail_title">退卡状态</view>
						<view class="detail_content" style="color: #E74c3c;">{{item.payState == 0 ? '退卡成功' : item.payState == 4 ? '退卡中' : '退卡失败'}}</view>
					</view>
					<view class="footer_slot" slot="footer">
						注：本次消费如有退款，将会在一分钟内原路退回支付账户，请在相关账户确认退款金额到账情况 <br>
					</view>
				</Bill>
			</view>
		</view>
		<view class="no_query" v-if="!showQuery">
			没有查到相关退卡记录
		</view>
	</view>
</template>

<script>
	import {
		cashQuery
	} from '../../common/api/index.js'
	import Bill from '@/components/bill/bill.vue'
	export default {
		components: {
			Bill
		},
		data() {
			return {
				billDetail: {},
				orgId: '',
				empId: '',
				showQuery: false
			};
		},
		onLoad(options) {
			this.orgId = options.orgId
			this.empId = options.empId
			this._cashQuery()
		},
		methods: {
			_cashQuery() {
				cashQuery({
					"empId": this.empId,
					"orgId": this.orgId
				}).then(res => {
					if(res.code == 0){
						if(res.data.length > 0){
							this.billDetail = res.data
							this.showQuery = true
						}else {
							this.showQuery = false
						}
					}else {
						uni.showToast({
							icon: 'none',
							title: res.msg,
							duration: 1500
						})
					}
				}).catch(err => {
					console.log(err)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		height: 100vh;
		background-color: #F1F0F5;
	}

	.bill {
		background: #FFF;
		margin: 0 24upx;
	}

	.footer_slot {
		padding: 32upx 0;
		color: #858b9c;
		font-size: 22upx;
		line-height: 1.5;
		border-top: 1px solid #e1e4eb;
	}

	.detail_item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		line-height: 1.35;
		font-size: 28upx;
		padding-top: 12upx;
		padding-bottom: 12upx;

		.detail_title {
			flex-shrink: 0;
			color: #858b9c;
		}

		.detail_content {
			flex: 1 1 0%;
			color: #41485d;
			display: flex;
			align-items: center;
			justify-content: flex-end;
			margin-left: 12px;

			&.advance_amount {
				color: #E74c3c;
				font-size: 46upx;
			}

			&.refund_amount {
				color: #F0AD4E;
				font-size: 46upx;
			}

			.paytype_icon {
				width: 32upx;
				height: 32upx;
				line-height: 32upx;
				margin-right: 10upx;
			}

			.icon_box {
				display: flex;
				align-items: center;
				justify-content: flex-end;
			}
		}
	}
	.no_query{
		padding: 100upx 24upx;
		text-align: center;
		font-size: 32upx;
	}
</style>
